package com.bawei.mall.user.remote.factory;

import com.bawei.common.core.domain.R;
import com.bawei.mall.user.remote.api.IRemoteUserService;
import com.bawei.system.domain.model.LoginUser;
import com.bawei.system.domain.model.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Author：韩丹阳
 * @Package：com.bawei.mall.user.remote.factory
 * @Project：mall_cloud
 * @name：RemoteUserFallbackFactory
 * @Date：2024/6/28 下午 04:10
 */
@Component
public class RemoteUserFallbackFactory implements FallbackFactory<IRemoteUserService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteUserFallbackFactory.class);
    @Override
    public IRemoteUserService create(Throwable cause) {
        log.error("用户服务调用失败:{}", cause.getMessage());
        return new IRemoteUserService() {
            @Override
            public R<User> userLogin(String username) {
                return R.fail("获取用户失败："+cause.getMessage());
            }
        };
    }
}
